package cn.edu.zafu.bigdata.lyq.work9;
import java.io.*;
import java.net.*;
public class TCPServer {
    public static void main(String[] args) {
        try{
            ServerSocket server =new ServerSocket(8888);
            Socket socket = server.accept();
            BufferedReader in =new BufferedReader(new InputStreamReader(socket.getInputStream()));
            PrintWriter out = new PrintWriter(socket.getOutputStream());
            BufferedReader sin =new BufferedReader(new InputStreamReader(System.in));
            String s;
            while (!(s= in.readLine()).equals("bye")){
                System.out.println("客户端回复：" +s);
                out.println(sin.readLine());
                out.flush();
            }
            System.out.println("通信结束！");
            in.close();
            out.close();
            socket.close();
            server.close();
        }catch (Exception e){
            System.out.println("Error:" +e);
        }
    }
}
